home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1999 November / SGI IRIX 6.5 Applications 1999 November.iso / dev / insight_dev.idb / usr / share / Insight / samples / SGIHelp / exampleDoc / installtestbooks.z / installtestbooks
Encoding:
Text File  |  1998-10-28  |  7.5 KB  |  241 lines

  1. #!/bin/sh
  2.  
  3. # This script installs your books into the Insight bookshelves under SGI_Test.
  4. # It also copies the helpmaps to the appropriate location.
  5. # This was created for test purposes only. 
  6. # This script must be run from the directory that the book was built in
  7. # and you must be logged in as root. 
  8. #
  9. # TO INSTALL A BOOK
  10. # If you are installing a book that contains help, it would be a good
  11. # idea if you did a "versions remove *.books.{BOOKNAME}" before using
  12. # this script.
  13. # Syntax: installtestbooks 
  14. #
  15. # Run "make pub_book" before running this script, if you want
  16. # anyone to be able to read this book from Insight on your machine.
  17. #
  18. # If the current bookshelf does not exist you will get a Warning that looks
  19. # like the following:
  20. #     Warning: Could not rename /usr/share/Insight/library/SGI_bookshelves/SGI_Test/booklist.txt
  21. #    to /usr/share/Insight/library/SGI_bookshelves/SGI_Test/booklist.txt.O
  22. #    insigtAdmin: No such file or directory
  23. # This is just a warning and the book should work fine.
  24. #
  25. # TO REMOVE A BOOK
  26. # Use the remove part of this script the same way you would use the install part.
  27. # This assumes that you have a Makefile with the proper variables and that the
  28. # variables have not changed since the book was installed.
  29. # Syntax: installtestbooks rem
  30. #
  31. # This was written for the 3.3 book build tools on IRIX 5.3
  32. # by Derrald Vogt.
  33. #
  34. #
  35. #
  36. # REVISION HISTORY
  37. #
  38. # 3-12-95    Revised script to remove books installed with this 
  39. #        script.
  40. #        Fixed a problem which would blow away the bookshelf
  41. #        that the book was being installed on. The original
  42. #        script was picking up spaces in front of the bookname
  43. #        which confused insightAdmin.
  44. #        Also made the script more readable.
  45. #
  46. # 1-19-95    Original script written on 1-19-95. This allowed 
  47. #        user to install books in work to a Test Bookshelf.
  48.  
  49.  
  50. # THIS SECTION DEFINES ALL THE VARIABLES
  51. # -------------------------------------------------------------------
  52. # -------------------------------------------------------------------
  53. # Checks to make sure that user is root; if not the script exits.
  54. echo ""
  55. if [ `whoami` != root ] ; then
  56.     echo "You must be root to run this script."
  57.     echo ""
  58.     exit
  59. fi
  60.  
  61.  
  62. # -------------------------------------------------------------------
  63. # Defines Title in the Makefile. If the Title is not present the script exits.
  64. # BOOKNAME=`grep '^TITLE' Makefile | sed 's/^.\{8\}//'`
  65.  
  66. BOOKNAME=`grep '^TITLE' Makefile | sed 's/^[     ]*TITLE[     ]*=[     ]*\([^     ]*\)$/\1/'`
  67.  
  68. if [ -z "$BOOKNAME" ] ; then
  69.     echo ""
  70.     echo "No short title was defined for this book."
  71.     echo ""
  72.     exit
  73. fi
  74.  
  75.  
  76. # -------------------------------------------------------------------
  77. # Defines the Bookshelf path. If no path is specified the default is used. 
  78. # This is used to warn the user that the book may already be installed.
  79.  
  80. SHELF2=`grep '^BOOKSHELF' Makefile | sed 's/^[     ]*BOOKSHELF[     ]*=[     ]*\([^     ]*\)$/\1/'`
  81.  
  82. if [ -z "$SHELF2" ] ; then
  83.     SHELF2=/usr/share/Insight/library/SGI_bookshelves/SGI_EndUser
  84. fi
  85.  
  86.  
  87. # -------------------------------------------------------------------
  88. # Defines the language of the book. If no langaue is specified in the Makefile
  89. # the default of C is used.
  90.  
  91. BOOK=`grep '^BOOK_LANG' Makefile | sed 's/^[     ]*BOOK_LANG[     ]*=[     ]*\([^     ]*\)$/\1/'`
  92.  
  93. if [ -z "$BOOK" ] ; then
  94.     BOOK=C
  95. fi
  96.  
  97.  
  98. # -------------------------------------------------------------------
  99. # Checks to see what bookshelf the book should be installed on.
  100. # SHELF1=`grep '^BOOKSHELF' Makefile | sed 's/^.\{12\}//' | cut -f1-6 -d/ `
  101.  
  102. SHELF1=`grep '^BOOKSHELF' Makefile | sed 's/^[     ]*BOOKSHELF[     ]*=[     ]*\([^     ]*\)$/\1/'  | cut -f1-6 -d/ `
  103.         
  104. if [ -z "$SHELF1" ] ; then
  105.            SHELF=/usr/share/Insight/library/SGI_bookshelves/SGI_Test
  106. else
  107.            SHELF=$SHELF1/SGI_Test
  108. fi
  109.  
  110. # ---------------------------------------------------------------------
  111. # Checks for the existence of a help directory
  112.  
  113. if [ -d help ] ; then
  114.         if [ $BOOK = C ] ; then
  115.                 HELP=/usr/share/help
  116.         else
  117.                 HELP=/usr/share/help/$BOOK
  118.         fi
  119.  
  120.     MAPS=`cd help ; ls *`
  121. fi
  122.  
  123.  
  124. # ---------------------------------------------------------------------
  125. # This prints the name values of the variables defined above.
  126.  
  127. echo "The current short title of the book is: $BOOKNAME"
  128. echo "The current book language is: $BOOK"
  129. echo $BOOKNAME "will be installed in" $SHELF
  130. echo "The value of SHELF1 is" $SHELF1
  131. echo "The value of SHELF2 is" $SHELF2
  132. echo "The value of SHELF is" $SHELF
  133. echo "The value of HELP is" $HELP
  134.  
  135.  
  136. # ALL COPY AND REMOVE FUNCTIONS ARE PERFORMED AFTER THIS POINT.    
  137. # --------------------------------------------------------------------
  138. # --------------------------------------------------------------------
  139. # Copies the books subdirs and puts them in the Insight Directory.
  140.  
  141. if [ "$1" != rem ] ; then
  142.  
  143.     if [ -d "$SHELF2/books/$BOOKNAME" ] ; then
  144.             echo ""
  145.             echo $BOOKNAME "already exists on the "$SHELF2" bookshelf."
  146.             echo "You should use \"versions remove\" to remove "$BOOKNAME
  147.             echo "to avoid any potential conflicts."
  148.             echo "Do you want to exit now and do a \"versions remove\" (Y/N)? \c"
  149.             read response
  150.     else
  151.             response=N
  152.     fi
  153.  
  154.     if [ "$response" != N ] ; then
  155.         echo ""
  156.             echo "Exiting script so that a \"versions remove\" can be done on "$BOOKNAME
  157.         echo "Please read the man page on \"versions remove\" for more information."
  158.             echo ""
  159.         exit
  160.     fi
  161.  
  162. # This is where we copy the helpmap files
  163.     if [ -d help ] ; then
  164.         
  165.             if [ ! -d "$HELP" ] ; then
  166.                     mkdir -p $HELP
  167.             fi
  168.  
  169.             cp help/* $HELP/.
  170.             echo "A help directory is present and the contents have been copied to "$HELP
  171.     else
  172.             echo "A help directory is not present."
  173.     fi
  174.  
  175.     if [ -d $SHELF/books/$BOOKNAME ] ; then
  176.         rm -rf $SHELF/books/$BOOKNAME
  177.     fi
  178.  
  179.     mkdir -p $SHELF/books/$BOOKNAME
  180.      cp booklist.txt $SHELF/books/$BOOKNAME/.
  181.     cp -r books/$BOOKNAME/ebt $SHELF/books/$BOOKNAME/.
  182.     cp -r books/$BOOKNAME/figures $SHELF/books/$BOOKNAME/.
  183.     cp -r books/$BOOKNAME/index $SHELF/books/$BOOKNAME/.
  184.     cp -r books/$BOOKNAME/styles $SHELF/books/$BOOKNAME/.
  185.  
  186. # --------------------------------------------------------------------
  187. # This runs insightAdmin which adds the book to the bookshelf in Insight
  188.  
  189.     /usr/sbin/insightAdmin -f $SHELF
  190.      echo ""
  191.         echo "Finished copying books to "$SHELF
  192.         echo ""
  193. fi
  194.  
  195.  
  196. # --------------------------------------------------------------------
  197. # --------------------------------------------------------------------
  198.  
  199. # DERRALD -- ADD CONDITION HERE FOR REMOVING BOOKS
  200. if [ "$1" = rem ] ; then
  201.  
  202.     # This removes just the book
  203.     echo ""
  204.     echo "WARNING You are about to remove $BOOKNAME from the $SHELF bookshelf"
  205.     echo ""
  206.     echo "This assumes that you have a Makefile with the proper " 
  207.     echo "variables and that the variables have not changed"
  208.     echo "since the book was installed with this same script."
  209.     echo ""
  210.     echo "Are you sure you want to do this? (Y/N)? \c"
  211.                 read remove
  212.  
  213.         if [ "$remove" = Y ] ; then
  214.         if [ -d $SHELF/books/$BOOKNAME ] ; then
  215.                     rm -rf $SHELF/books/$BOOKNAME
  216.             /usr/sbin/insightAdmin -f $SHELF
  217.                 echo ""
  218.                    echo "Finished removing  books from "$SHELF
  219.                 echo ""
  220.             fi
  221.     fi
  222.     
  223.     # This removes the helpmaps
  224.         echo "WARNING You are about to remove the following helpmaps" 
  225.     echo $MAPS
  226.     echo "from the $HELP directory."
  227.         echo ""
  228.         echo "Are you sure you want to do this? (Y/N)? \c"
  229.                 read remhelp
  230.  
  231.         if [ "$remhelp" = Y ] ; then
  232.             cd $HELP ; rm -f $MAPS
  233.         echo "The helmaps have been removed from this book."
  234.         echo ""
  235.     fi
  236.     echo "Finished removing $BOOKNAME"
  237.     echo ""
  238. fi
  239.  
  240.